package com.atguigu.gmallrealtime.app.func;

import com.atguigu.gmallrealtime.util.KeywordUtil;
import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;

import java.io.IOException;
import java.util.ArrayList;

/**
 * @author yhm
 * @create 2023-10-08 15:39
 */
@FunctionHint(output = @DataTypeHint("ROW<word STRING>"))
public class KeywordUDTF  extends TableFunction<Row> {

    public void eval(String str) {
        try {
            ArrayList<String> strings = KeywordUtil.iKSplitWord(str);
            for (String string : strings) {
                collect(Row.of(string));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}